package vn.fpt.fsoft.menugame;

import java.awt.Graphics2D;
import java.awt.event.KeyEvent;

public abstract class GameScreen {

	public enum ScreenState {
		TransitionOn, Active, TransitionOff, Hidden,
	}

	protected ScreenManager screenManager;

	private boolean isPopup;

	private boolean isExisting;

	/**
	 * @return the isPopup
	 */
	public boolean isPopup() {
		return isPopup;
	}

	/**
	 * @param isPopup
	 *            the isPopup to set
	 */
	public void setPopup(boolean isPopup) {
		this.isPopup = isPopup;
	}

	/**
	 * @return the isExisting
	 */
	public boolean isExisting() {
		return isExisting;
	}

	/**
	 * @param isExisting
	 *            the isExisting to set
	 */
	public void setExisting(boolean isExisting) {
		this.isExisting = isExisting;
	}

	/**
	 * @return the screenState
	 */
	public ScreenState getScreenState() {
		return screenState;
	}

	/**
	 * @param screenState
	 *            the screenState to set
	 */
	public void setScreenState(ScreenState screenState) {
		this.screenState = screenState;
	}

	private ScreenState screenState = ScreenState.TransitionOn;

	/**
	 * @return the screenManager
	 */
	public ScreenManager getScreenManager() {
		return screenManager;
	}

	public GameScreen(ScreenManager screenManager) {
		this.screenManager = screenManager;
	}

	public void gameInit() {

	}

	public void gameShutdown() {

	}

	public abstract void gameKeyPressed(int keyCode);

	public void gameUpdate() {
		if (isExisting) {
			screenState = ScreenState.TransitionOff;
			// When the transition finishes, remove the screen.
			screenManager.removeScreen(this);
		}
	}

	public abstract void gameDraw(Graphics2D g);

	public void exitScreen() {
		isExisting = true;
		screenManager.removeScreen(this);
	}
}
